﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using OnlineShop.Models;
using OnlineShop.Common;
using OnlineShop.Models.ViewModels;

namespace OnlineShop.Controllers
{
    public class CategoryController : BaseController
    {
        #region Repository
        private IOnlineShopRepository repository;

        public CategoryController():this(new EFOnlineShopRepository())
        {
        }

        public CategoryController(EFOnlineShopRepository eFOnlineShopRepository)
        {
            this.repository = eFOnlineShopRepository;
        }

        #endregion

        [ChildActionOnly]
        public ActionResult List()
        {
            var listCategory = new List<CategoryModel>();

            foreach (var item in repository.GetListCategory())
            {
                listCategory.Add(item.ToModel());
            }

            return PartialView("CategorySidebar",listCategory);
        }

    }
}
